package com.linkage.educloud.ah.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr'Tang on 2018/9/10.
 */

public class ArticleBean implements Serializable {
    private String time;
    private int topic_id;
    private String topic_img;
    private String topic_title;

    public static List<ArticleBean> parseFromJson(JSONArray jsonArray) {
        List<ArticleBean> list = new ArrayList<>();
        for (int a = 0; a < jsonArray.length(); a++) {
            ArticleBean articleBean = new ArticleBean();
            JSONObject obj = null;
            try {
                obj = jsonArray.getJSONObject(a);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            articleBean.setTime(obj.optString("time"));
            articleBean.setTopic_id(obj.optInt("topic_id"));
            articleBean.setTopic_img(obj.optString("topic_img"));
            articleBean.setTopic_title(obj.optString("topic_title"));
            list.add(articleBean);
        }
        return list;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public int getTopic_id() {
        return topic_id;
    }

    public void setTopic_id(int topic_id) {
        this.topic_id = topic_id;
    }

    public String getTopic_img() {
        return topic_img;
    }

    public void setTopic_img(String topic_img) {
        this.topic_img = topic_img;
    }

    public String getTopic_title() {
        return topic_title;
    }

    public void setTopic_title(String topic_title) {
        this.topic_title = topic_title;
    }
}
